<?php

namespace app\company\model;

use app\common\model\BaseModel;
use app\common\service\SystemLogService;
use think\model\relation\BelongsTo;

class CompanyLog extends BaseModel
{
    protected $deleteTime = false;

    public function __construct(array $data = [])
    {
        parent::__construct($data);
        $this->name = 'company_log_' . date('Ym');
    }

    public function setMonth($month): static
    {
        SystemLogService::instance()->detectTable();
        $this->name = 'company_log_' . $month;
        return $this;
    }

    public function user(): BelongsTo
    {
        return $this->belongsTo(CompanyUser::class, 'company_user_id', 'id');
    }

}